

package com.hazelcast.client.impl.protocol.codec.custom;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.Generated;
import com.hazelcast.client.impl.protocol.codec.builtin.DataCodec;
import com.hazelcast.client.impl.protocol.codec.builtin.EntryListCodec;
import com.hazelcast.client.impl.protocol.codec.builtin.ListIntegerCodec;

import static com.hazelcast.client.impl.protocol.ClientMessage.BEGIN_FRAME;
import static com.hazelcast.client.impl.protocol.ClientMessage.END_FRAME;
import static com.hazelcast.client.impl.protocol.codec.builtin.CodecUtil.fastForwardToEndFrame;

@SuppressWarnings("unused")
@Generated("03d5c1a14b8aceff06f3070d5b4e7cf3")
public final class AnchorDataListHolderCodec {

    private AnchorDataListHolderCodec() {
    }

    public static void encode(ClientMessage clientMessage, com.hazelcast.client.impl.protocol.codec.holder.AnchorDataListHolder anchorDataListHolder) {
        clientMessage.add(BEGIN_FRAME.copy());

        ListIntegerCodec.encode(clientMessage, anchorDataListHolder.getAnchorPageList());
        EntryListCodec.encode(clientMessage, anchorDataListHolder.getAnchorDataList(), DataCodec::encode, DataCodec::encodeNullable);

        clientMessage.add(END_FRAME.copy());
    }

    public static com.hazelcast.client.impl.protocol.codec.holder.AnchorDataListHolder decode(ClientMessage.ForwardFrameIterator iterator) {
        // begin frame
        iterator.next();

        java.util.List<java.lang.Integer> anchorPageList = ListIntegerCodec.decode(iterator);
        java.util.List<java.util.Map.Entry<com.hazelcast.internal.serialization.Data, com.hazelcast.internal.serialization.Data>> anchorDataList = EntryListCodec.decode(iterator, DataCodec::decode, DataCodec::decodeNullable);

        fastForwardToEndFrame(iterator);

        return new com.hazelcast.client.impl.protocol.codec.holder.AnchorDataListHolder(anchorPageList, anchorDataList);
    }
}
